mirror of
https://github.com/espressif/openthread.git
synced 2026-09-05 08:40:06 +00:00
[mle] check netif is up before processing discover scan (#6919)
This commit updates `Mle::DiscoverScanner` to check that IPv6 interface is enabled from `Discover()` (returns `kErrorInvalidState` if netif is not up).
This commit is contained in:
@@ -53,7 +53,7 @@ extern "C" {
|
||||
* @note This number versions both OpenThread platform and user APIs.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_API_VERSION (151)
|
||||
#define OPENTHREAD_API_VERSION (152)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
|
||||
@@ -242,8 +242,10 @@ bool otThreadIsSingleton(otInstance *aInstance);
|
||||
* scan completes.
|
||||
* @param[in] aCallbackContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Accepted the Thread Discovery request.
|
||||
* @retval OT_ERROR_BUSY Already performing an Thread Discovery.
|
||||
* @retval OT_ERROR_NONE Successfully started a Thread Discovery Scan.
|
||||
* @retval OT_ERROR_INVALID_STATE The IPv6 interface is not enabled (netif is not up).
|
||||
* @retval OT_ERROR_NO_BUFS Could not allocate message for Discovery Request.
|
||||
* @retval OT_ERROR_BUSY Thread Discovery Scan is already in progress.
|
||||
*
|
||||
*/
|
||||
otError otThreadDiscover(otInstance * aInstance,
|
||||
|
||||
@@ -73,6 +73,8 @@ Error DiscoverScanner::Discover(const Mac::ChannelMask &aScanChannels,
|
||||
MeshCoP::DiscoveryRequestTlv discoveryRequest;
|
||||
MeshCoP::JoinerAdvertisementTlv joinerAdvertisement;
|
||||
|
||||
VerifyOrExit(Get<ThreadNetif>().IsUp(), error = kErrorInvalidState);
|
||||
|
||||
VerifyOrExit(mState == kStateIdle, error = kErrorBusy);
|
||||
|
||||
mEnableFiltering = aEnableFiltering;
|
||||
|
||||
@@ -115,9 +115,10 @@ public:
|
||||
* @param[in] aHandler A pointer to a function that is called on receiving an MLE Discovery Response.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*
|
||||
* @retval kErrorNone Successfully started a Thread Discovery Scan.
|
||||
* @retval kErrorNoBufs Could not allocate message for Discovery Request.
|
||||
* @retval kErrorBusy Thread Discovery Scan is already in progress.
|
||||
* @retval kErrorNone Successfully started a Thread Discovery Scan.
|
||||
* @retval kErrorInvalidState The IPv6 interface is not enabled (netif is not up).
|
||||
* @retval kErrorNoBufs Could not allocate message for Discovery Request.
|
||||
* @retval kErrorBusy Thread Discovery Scan is already in progress.
|
||||
*
|
||||
*/
|
||||
Error Discover(const Mac::ChannelMask &aScanChannels,
|
||||
|
||||
@@ -78,6 +78,8 @@ expect -re "\\| +$channel \\| +-?\\d+ \\|"
|
||||
expect_line "Done"
|
||||
|
||||
switch_node 3
|
||||
send "discover\n"
|
||||
expect "Error 13: InvalidState"
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
send "discover $channel\n"
|
||||
|
||||
Reference in New Issue
Block a user