[mle] add parent request callback config (#8989)

This commit adds `MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE` config
which enables support for `otThreadRegisterParentResponseCallback()`
API. This API registers a callback to notify user of received
Parent Response message(s) during attach. This API is mainly intended
for debugging and therefore is is disabled by default. It is enabled
in `toranj-config` so to validate the code (i.e. it causes no build
errors) during CI GitHub action runs.
This commit is contained in:
Abtin Keshavarzian
2023-04-28 20:36:42 -07:00
committed by GitHub
parent 0ce28ba1c2
commit c59eb37c60
10 changed files with 40 additions and 2 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ extern "C" {
* @note This number versions both OpenThread platform and user APIs.
*
*/
#define OPENTHREAD_API_VERSION (314)
#define OPENTHREAD_API_VERSION (315)
/**
* @addtogroup api-instance
+4
View File
@@ -922,6 +922,8 @@ void otThreadResetMleCounters(otInstance *aInstance);
/**
* This function pointer is called every time an MLE Parent Response message is received.
*
* This is used in `otThreadRegisterParentResponseCallback()`.
*
* @param[in] aInfo A pointer to a location on stack holding the stats data.
* @param[in] aContext A pointer to callback client-specific context.
*
@@ -931,6 +933,8 @@ typedef void (*otThreadParentResponseCallback)(otThreadParentResponseInfo *aInfo
/**
* This function registers a callback to receive MLE Parent Response data.
*
* This function requires `OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE`.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aCallback A pointer to a function that is called upon receiving an MLE Parent Response message.
* @param[in] aContext A pointer to callback client-specific context.
+2
View File
@@ -436,12 +436,14 @@ const otMleCounters *otThreadGetMleCounters(otInstance *aInstance)
void otThreadResetMleCounters(otInstance *aInstance) { AsCoreType(aInstance).Get<Mle::MleRouter>().ResetCounters(); }
#if OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE
void otThreadRegisterParentResponseCallback(otInstance *aInstance,
otThreadParentResponseCallback aCallback,
void *aContext)
{
AsCoreType(aInstance).Get<Mle::MleRouter>().RegisterParentResponseStatsCallback(aCallback, aContext);
}
#endif
#if OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE
otError otThreadLocateAnycastDestination(otInstance *aInstance,
+12
View File
@@ -272,6 +272,18 @@
#define OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH 1
#endif
/**
* @def OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE
*
* Define as 1 to support `otThreadRegisterParentResponseCallback()` API which registers a callback to notify user
* of received Parent Response message(s) during attach. This API is mainly intended for debugging and therefore is
* disabled by default.
*
*/
#ifndef OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE
#define OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE
*
+2 -1
View File
@@ -3153,7 +3153,7 @@ void Mle::HandleParentResponse(RxInfo &aRxInfo)
cslAccuracy.Init();
#endif
// Share data with application, if requested.
#if OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE
if (mParentResponseCallback.IsSet())
{
otThreadParentResponseInfo parentinfo;
@@ -3169,6 +3169,7 @@ void Mle::HandleParentResponse(RxInfo &aRxInfo)
mParentResponseCallback.Invoke(&parentinfo);
}
#endif
aRxInfo.mClass = RxInfo::kAuthoritativeMessage;
+4
View File
@@ -624,6 +624,7 @@ public:
*/
void ResetCounters(void) { memset(&mCounters, 0, sizeof(mCounters)); }
#if OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE
/**
* This function registers the client callback that is called when processing an MLE Parent Response message.
*
@@ -635,6 +636,7 @@ public:
{
mParentResponseCallback.Set(aCallback, aContext);
}
#endif
/**
* This method requests MLE layer to prepare and send a shorter version of Child ID Request message by only
@@ -2135,7 +2137,9 @@ private:
DetachGracefullyTimer mDetachGracefullyTimer;
Callback<otDetachGracefullyCallback> mDetachGracefullyCallback;
#if OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE
Callback<otThreadParentResponseCallback> mParentResponseCallback;
#endif
};
} // namespace Mle
+2
View File
@@ -285,7 +285,9 @@ NcpBase::NcpBase(Instance *aInstance)
#if OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE
memset(&mSteeringDataAddress, 0, sizeof(mSteeringDataAddress));
#endif
#if OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE
otThreadRegisterParentResponseCallback(mInstance, &NcpBase::HandleParentResponseInfo, static_cast<void *>(this));
#endif
#endif // OPENTHREAD_FTD
#if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE
otSrpClientSetCallback(mInstance, HandleSrpClientCallback, this);
+2
View File
@@ -272,8 +272,10 @@ protected:
static void HandleNeighborTableChanged(otNeighborTableEvent aEvent, const otNeighborTableEntryInfo *aEntry);
void HandleNeighborTableChanged(otNeighborTableEvent aEvent, const otNeighborTableEntryInfo &aEntry);
#if OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE
static void HandleParentResponseInfo(otThreadParentResponseInfo *aInfo, void *aContext);
void HandleParentResponseInfo(const otThreadParentResponseInfo &aInfo);
#endif
#endif
static void HandleDatagramFromStack(otMessage *aMessage, void *aContext);
+2
View File
@@ -85,6 +85,7 @@ exit:
// MARK: Property/Status Changed
// ----------------------------------------------------------------------------
#if OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE
void NcpBase::HandleParentResponseInfo(otThreadParentResponseInfo *aInfo, void *aContext)
{
VerifyOrExit(aInfo && aContext);
@@ -116,6 +117,7 @@ void NcpBase::HandleParentResponseInfo(const otThreadParentResponseInfo &aInfo)
exit:
return;
}
#endif
void NcpBase::HandleNeighborTableChanged(otNeighborTableEvent aEvent, const otNeighborTableEntryInfo *aEntry)
{
@@ -557,6 +557,15 @@
*/
#define OPENTHREAD_CONFIG_CLI_REGISTER_IP6_RECV_CALLBACK 1
/**
* @def OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE
*
* Define as 1 to support `otThreadRegisterParentResponseCallback()` API which registers a callback to notify user
* of received Parent Response message(s) during attach.
*
*/
#define OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE 1
#if OPENTHREAD_RADIO
/**
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE