Skip to content

Commit

Permalink
[posix] expose platformInfraIfIsRunning() as `otSysInfraIfIsRunning…
Browse files Browse the repository at this point in the history
…()` (#9672)

When we are switching to another infra netif via
`otBorderRoutingInit()`, we may want to read the state of the new
infra netif via `otSysInfraIfIsRunning()`.
  • Loading branch information
superwhd authored Dec 5, 2023
1 parent 19af711 commit 11622a1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 8 additions & 0 deletions src/posix/platform/include/openthread/openthread-system.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,14 @@ void otSysCountInfraNetifAddresses(otSysInfraNetIfAddressCounters *aAddressCount
*/
void otSysSetInfraNetif(const char *aInfraNetifName, int aIcmp6Socket);

/**
* Returns TRUE if the infrastructure interface is running.
*
* @returns TRUE if the infrastructure interface is running, FALSE if not.
*
*/
bool otSysInfraIfIsRunning(void);

#ifdef __cplusplus
} // end of extern "C"
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/posix/platform/infra_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ otError otPlatInfraIfDiscoverNat64Prefix(uint32_t aInfraIfIndex)
#endif
}

bool platformInfraIfIsRunning(void) { return ot::Posix::InfraNetif::Get().IsRunning(); }
bool otSysInfraIfIsRunning(void) { return ot::Posix::InfraNetif::Get().IsRunning(); }

const char *otSysGetInfraNetifName(void) { return ot::Posix::InfraNetif::Get().GetNetifName(); }

Expand Down Expand Up @@ -452,7 +452,7 @@ void InfraNetif::SetUp(void)
VerifyOrExit(mNetLinkSocket != -1);

#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
SuccessOrDie(otBorderRoutingInit(gInstance, mInfraIfIndex, platformInfraIfIsRunning()));
SuccessOrDie(otBorderRoutingInit(gInstance, mInfraIfIndex, otSysInfraIfIsRunning()));
SuccessOrDie(otBorderRoutingSetEnabled(gInstance, /* aEnabled */ true));
#endif

Expand Down Expand Up @@ -546,7 +546,7 @@ void InfraNetif::ReceiveNetLinkMessage(void)
case RTM_NEWLINK:
case RTM_DELLINK:
#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
SuccessOrDie(otPlatInfraIfStateChanged(gInstance, mInfraIfIndex, platformInfraIfIsRunning()));
SuccessOrDie(otPlatInfraIfStateChanged(gInstance, mInfraIfIndex, otSysInfraIfIsRunning()));
#endif
break;
case NLMSG_ERROR:
Expand Down
8 changes: 0 additions & 8 deletions src/posix/platform/platform-posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,6 @@ extern unsigned int gNetifIndex;
*/
extern otInstance *gInstance;

/**
* Tells if the infrastructure interface is running.
*
* @returns TRUE if the infrastructure interface is running, FALSE if not.
*
*/
bool platformInfraIfIsRunning(void);

/**
* Initializes backtrace module.
*
Expand Down

0 comments on commit 11622a1

Please sign in to comment.