mirror of
https://github.com/espressif/openthread.git
synced 2026-08-01 08:37:47 +00:00
[backbone-router] add deinit API (#6817)
This fixes the infinite loop when OTBR is pseudo-reset by DBus API.
This commit is contained in:
@@ -69,6 +69,17 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void platformBackboneDeinit(void)
|
||||
{
|
||||
#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
|
||||
sMulticastRoutingManager.Deinit();
|
||||
#endif
|
||||
|
||||
gBackboneNetifIndex = 0;
|
||||
|
||||
memset(gBackboneNetifName, 0, sizeof(gBackboneNetifName));
|
||||
}
|
||||
|
||||
void platformBackboneStateChange(otInstance *aInstance, otChangedFlags aFlags)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
@@ -60,6 +60,12 @@ void MulticastRoutingManager::Init(otInstance *aInstance)
|
||||
Mainloop::Manager::Get().Add(*this);
|
||||
}
|
||||
|
||||
void MulticastRoutingManager::Deinit(void)
|
||||
{
|
||||
Mainloop::Manager::Get().Remove(*this);
|
||||
otBackboneRouterSetMulticastListenerCallback(mInstance, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void MulticastRoutingManager::HandleBackboneMulticastListenerEvent(void * aContext,
|
||||
otBackboneRouterMulticastListenerEvent aEvent,
|
||||
const otIp6Address * aAddress)
|
||||
|
||||
@@ -48,17 +48,9 @@
|
||||
namespace ot {
|
||||
namespace Posix {
|
||||
|
||||
/**
|
||||
* This class implements Multicast Routing management.
|
||||
*
|
||||
*/
|
||||
class MulticastRoutingManager : public Mainloop::Source, private NonCopyable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This constructor initializes a Multicast Routing manager instance.
|
||||
*
|
||||
*/
|
||||
explicit MulticastRoutingManager()
|
||||
|
||||
: mLastExpireTime(0)
|
||||
@@ -66,37 +58,10 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes the Multicast Routing manager.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
*/
|
||||
void Init(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* This method updates the fd_set and timeout for mainloop.
|
||||
*
|
||||
* @param[inout] aContext A reference to the mainloop context.
|
||||
*
|
||||
*/
|
||||
void Deinit(void);
|
||||
void Update(otSysMainloopContext &aContext) override;
|
||||
|
||||
/**
|
||||
* This method performs Multicast Routing processing.
|
||||
*
|
||||
* @param[in] aContext A reference to the mainloop context.
|
||||
*
|
||||
*/
|
||||
void Process(const otSysMainloopContext &aContext) override;
|
||||
|
||||
/**
|
||||
* This method handles Thread state changes.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aFlags Flags that denote the state change events.
|
||||
*
|
||||
*/
|
||||
void HandleStateChange(otInstance *aInstance, otChangedFlags aFlags);
|
||||
|
||||
private:
|
||||
|
||||
@@ -436,6 +436,12 @@ extern unsigned int gNetifIndex;
|
||||
*/
|
||||
void platformBackboneInit(otInstance *aInstance, const char *aInterfaceName);
|
||||
|
||||
/**
|
||||
* This function shuts down the platform Backbone network.
|
||||
*
|
||||
*/
|
||||
void platformBackboneDeinit(void);
|
||||
|
||||
/**
|
||||
* This function performs notifies state changes to platform Backbone network.
|
||||
*
|
||||
|
||||
@@ -177,6 +177,10 @@ void otSysDeinit(void)
|
||||
#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||
ot::Posix::InfraNetif::Get().Deinit();
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
|
||||
platformBackboneDeinit();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if OPENTHREAD_POSIX_VIRTUAL_TIME
|
||||
|
||||
Reference in New Issue
Block a user